// custom-tab-bar/index.js
// 自定义tabBar官方文档：
// https://developers.weixin.qq.com/miniprogram/dev/framework/ability/custom-tabbar.html
Component({
  data: {
    selected: 0,
    color: "#777777",
    selectedColor: "#1989fa",
    list: [
      {
        text: "首页",
        pagePath: "pages/index/index",
        iconPath: "",
        selectedIconPath: "",
      },
      {
        text: "分类",
        pagePath: "pages/classify/classify",
        iconPath: "",
        selectedIconPath: "",
      },
      {
        text: "发布",
        pagePath: "pages/release/release",
        iconPath: "",
        selectedIconPath: "",
      },
      {
        text: "我的",
        pagePath: "pages/user/user",
        iconPath: "",
        selectedIconPath: "",
      },
    ],
  },
  attached() {},
  methods: {
    onChange(event) {
      this.setData({ active: event.detail });
      const data =  this.data.list[event.detail]
      const url = '/'+data.pagePath;
      wx.switchTab({ url });
      this.setData({
        selected: event.detail,
      });
    },
  },
});
